﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Configuration
Imports System.Drawing
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class discusList
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        hiddenUserName.Value = Context.User.Identity.Name
        lblmess.Visible = False
    End Sub

    Protected Sub btnDiscuss_Click(sender As Object, e As EventArgs) Handles btnDiscuss.Click
        Me.ModalPopupExtender1.Show()
        End Sub

    Protected Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        Dim tusername As String = hiddenUserName.Value
        If txtTopic.Text <> "" Then
            Dim dbdate As DateTime
            Dim dbtime As TimeSpan
            dbdate = Now.Date
            dbtime = Now.TimeOfDay
            Dim con As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("fishconn").ConnectionString)
            con.Open()
            Dim cmd As New OleDbCommand("insert into tblDiscussion (DiscussionSubject, Username, CreatedDate, CreatedTime) values(@topic, @Username, @CreatedDate, @CreatedTime)", con)
            cmd.Parameters.AddWithValue("@topic", txtTopic.Text)
            cmd.Parameters.AddWithValue("@Username", tusername)
            cmd.Parameters.AddWithValue("@CreatedDate", dbdate)
            cmd.Parameters.AddWithValue("@CreatedTim", dbtime)
            cmd.ExecuteNonQuery()
            con.Close()
            Response.Redirect("~/discuslist.aspx")
        End If
    End Sub
End Class